package com.cskaoyan.jdbc.crud;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/11/16 16:17
 *
 * @author ciggar
 */
public class UpdateDemo {

    public static void main(String[] args) throws SQLException {

        // 1. 获取连接
        Connection connection = JDBCUtils.getConnection();

        // 2. 获取statement对象
        Statement statement = connection.createStatement();

        // 3. 执行SQL语句
        int affectedRows = statement.executeUpdate("update stu set name = '李云龙' where id = 1002");

        // 4. 解析结果集
        System.out.println("affectedRows:" + affectedRows);

        // 5. 关闭资源
        JDBCUtils.closeResources(null,statement,connection);
    }
}
